class Solution {
public:
    int mySqrt(int x) {
        double ans = x;
        double pre=0;
        while (int(ans)!=int(pre)) {
            pre = ans;
            ans = (ans + x / ans) / 2;
        }
        return ans;
    }
};